﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Favorites;
public partial class Search_SaveFavorites : Base.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string ThisUrl = Request.Url.ToString();
        int intUserID = 0;
        if (Base.GetRequest.GetQueryStringValue("id") != "" && Base.GetRequest.GetQueryStringValue("type") != "")
        {
            string strType = Request.QueryString["type"].ToString();
            string strID = Request.QueryString["id"].ToString();
            try
            {
                if (CheckCookies())
                {
                    intUserID = int.Parse(GetCookie("UserID"));
                    Favorites.TFavorites tf = new TFavorites();
                    tf.UserID = intUserID;
                    tf.Type = strType;
                    tf.ProductID = int.Parse(strID.ToString());
                    int Reint = new RFavorites().Insert(tf);
                    if (Reint == 1)
                    {
                        if (strType != "company")
                            ShowMessage("信息收藏成功！", "../member/index.aspx");
                        else
                            ShowMessage("信息收藏成功！");
                    }
                }
                else
                    Response.Redirect("../login/login.aspx?done=" + ThisUrl);
            }
            catch (Exception ex)
            {
                if (strType != "company")
                    ShowMessage("已经存在该收藏!", "../Member/index.aspx");
                else
                    ShowMessage("已经存在该收藏!");
            }
        }
    }
}
